package servise

import (
	"github.com/emicklei/go-restful/v3"
	"hxy/repo/cmd"
	errors "hxy/repo/error"
	"hxy/repo/monitor"
)

func HandleGetMonitorPool(request *restful.Request, response *restful.Response) {
	list, re := monitor.GetAllGitMonitor()
	if re.Error != nil {
		errors.HandleInternalError(response, re.Error)
		return
	}
	response.WriteAsJson(list)
}

func HandlerLogWebsocket(request *restful.Request, response *restful.Response) {
	var id = request.PathParameter("logid")
	cmd.ServeLogWs(response.ResponseWriter, request.Request, id)
}

func HandlerDockerLogsocket(request *restful.Request, response *restful.Response) {
	var hash = request.QueryParameter("hash")
	var name = request.QueryParameter("name")
	cmd.ServeLogWs(response.ResponseWriter, request.Request, hash+"/"+name)
}
